<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../../_template.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="centro">
        <h:form >
            <p:outputLabel value="Conta" style="font-size: x-large; margin-left: 25px" styleClass="labelInserir" /> 
            <p:fieldset styleClass="fieldsetInsert" style=" margin-left: 25px">
                <p:messages />
                <h:panelGrid columns="1">
                    <p:outputLabel value="Tipo de conta:" for="tipoConta" rendered="#{!contaBean.habilitaTipoConta}" />

                    <p:selectOneMenu id="tipoConta" value="#{contaBean.tipoConta}" rendered="#{contaBean.habilitaTipoConta}" 
                                     required="true" requiredMessage="Informe o tipo de conta!" >
                        <f:selectItem itemLabel="Escolha uma opção" noSelectionOption="true"/>
                        <f:selectItems value="#{contaBean.tiposConta}"  var="lista" itemLabel="#{lista.tipoConta}"/>
                    </p:selectOneMenu>
                </h:panelGrid>
                <br />
                <p:commandButton value="Novo" action="#{contaBean.novo}" icon="ui-icon-plus"  ajax="false" />
                <br />
                <br />
            </p:fieldset>
        </h:form>
        <h:form>

            <p:dataTable value="#{contaBean.contas}" rendered="#{not empty contaBean.contas}" var="conta" emptyMessage="Nenhum registro encontrado!" style=" margin-left: -75px">                        

                <p:column style="text-align: left;" headerText="Banco" >
                    <h:outputText value="#{conta.banco.nomeBanco}" >
                        <f:converter converterId="convertUpper" /> 
                    </h:outputText>
                </p:column>
                <p:column style="text-align: left;" headerText="Conta" >
                    <h:outputText value="#{conta.nome}">
                        <f:converter converterId="convertUpper" /> 
                    </h:outputText>
                </p:column>
                <p:column style="text-align: left;" headerText="Situação" >
                    <h:outputText value="#{conta.situacao}">
                        <f:converter converterId="convertUpper" /> 
                    </h:outputText>
                </p:column>
                <p:column style="text-align: left;" headerText="Saldo" >
                    <h:outputText value="#{conta.saldo}">
                        <f:convertNumber type="currency" locale="pt_br" />
                    </h:outputText>
                </p:column>
                <p:column style="width: 10px;" headerText="Alterar">
                    <center>
                        <p:commandButton action="#{contaBean.alterar(conta)}" icon="ui-icon-pencil" ajax="false" />
                    </center>
                </p:column>
                <p:column style="width: 10px;" headerText="Excluir">
                    <center>
                        <p:commandButton icon="ui-icon-trash" actionListener="#{contaBean.remover(conta)}" update="@all" >
                            <p:confirm header="Confirmação" message="Deseja realmente excluir a informação?" icon="ui-icon-alert" />
                        </p:commandButton>
                    </center>
                </p:column>
            </p:dataTable><br/>
            <p:confirmDialog global="true" showEffect="fade" id="Confirmação" >
                <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
                <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
            </p:confirmDialog>

        </h:form>
    </ui:define>
</ui:composition>

